<template>
	<view class="pact">
		<u-parse :content="data" ></u-parse>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data:'加载中...', // 合同信息
				pid:'', // 判断跳转的途径 1：关于我们 2：软件使用许可协议 3：隐私协议
			}
		},
		onLoad(res) {
			this.pid = res.pid
			this.lookClick(res.pid)
		},
		onReady() {
			uni.setNavigationBarTitle({
			    title: ['','关于我们','软件使用许可协议','隐私协议'][this.pid]
			});
		},
		methods:{
			/**
			 * 请求合同内容
			 * @param {string} index 判断跳转的途径 1：关于我们 2：软件使用许可协议 3：隐私协议
			 */
			async lookClick(index) {
				try{
					let res = await this.$http.get('/index/Communal/config_data',{
						config_id:3
					})
					// if(index == 1) this.data = res.aboutus.value.replace(/src="\//g, 'class="img-14" src="https://www.zhuoxianrenli.cn/') || '暂无数据！';
					if(index == 1) this.data = res.aboutus.value.replace(/src="\//g, `class="img-14" src="${getApp().globalData.url}`) || '暂无数据！';
					// else if(index == 2) this.data = res.agreement.value.replace(/src="\//g, 'class="img-14" src="https://www.zhuoxianrenli.cn/') || '暂无数据！';
					else if(index == 2) this.data = res.agreement.value.replace(/src="\//g, `class="img-14" src="${getApp().globalData.url}`) || '暂无数据！';
					// else if(index == 3) this.data = res.privacy.value.replace(/src="\//g, 'class="img-14" src="https://www.zhuoxianrenli.cn/') || '暂无数据！';
					else if(index == 3) this.data = res.privacy.value.replace(/src="\//g, `class="img-14" src="${getApp().globalData.url}`) || '暂无数据！';
				}catch(e){
					//TODO handle the exception
					uni.showToast({
						title: e.errMsg,
						icon:"none"
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}
	.pact {
		box-sizing: border-box;
		width: 100%;
		padding:20rpx 32rpx;
		.p-main {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			box-sizing: border-box;
			width: 100%;
			height: 100%;
			padding: 38rpx 26rpx;
			background-color: #ffffff;
			.p-m-body {
				flex: 1;
				display: flex;
				flex-direction: column;
				box-sizing: border-box;
				margin-bottom: 158rpx;
				.b-title {
					width: 100%;
					text-align: center;
					margin-bottom: 60rpx;
					.b-t-text {
						font-size: 34rpx;
						font-weight: 600;
						color: #000000;
					}
				}
				.b-list {
					width: 100%;
					margin-bottom: 20rpx;
					.l-text {
						line-height: 2;
						font-size: 26rpx;
						font-weight: 600;
						color: #131313;
					}
					.l-text1 {
						color: #4D4D4D;
					}
				}
				.b-com {
					.c-text {
						line-height: 2;
						font-size: 26rpx;
						font-weight: 600;
						color: #141414;
					}
				}
			}
			.p-m-end {
				display: flex;
				flex-direction: column;
				align-items: center;
				.set {
					display: flex;
					justify-content: center;
					align-items: center;
					.s-text {
						font-size: 20rpx;
						font-weight: 600;
						color: #666666;
					}
				}
				.but {
					display: flex;
					justify-content: center;
					box-sizing: border-box;
					width: 100%;
					padding:0 32rpx;
					margin: 40rpx 0;
					.butt {
						width: 100%;
						font-size: 34rpx;
						font-weight: 600;
						color: #FFFFFF;
						background: linear-gradient(-90deg, #8dc9f1, #d8eefc);
						border-radius: 40rpx;
						line-height: 80rpx;
						border: 0;
						margin: 0;
					}
				}
			}
		}
	}
</style>
